function evalmany(cmd,varargin);% evalmany(command_to_evaluate,sublist1,sublist2,...);%% evaluates a command with _eval_ iteratively, substituting every occurrence of% '$1' with the strings in the cell array sublist1, '$2' with the strings in% sublist2, etc.%% e.g.%    evalmany('M$1 = $2;',{'a','b','c'},{'2','4','6'});% is equivalent to%    Ma = 2;%    Mb = 4;%    Mc = 6;%% neil banas mar 2009verbose = 0;N = length(varargin);M = length(varargin{1});for n=2:N	if length(varargin{n})~=M, error('sub lists should all be the same length.'); end;endfor m=1:M	cmdm = cmd;	for n=1:N		cmdm = strrep(cmdm,['$' num2str(n)],varargin{n}{m});	end	if verbose, disp(cmdm); end	evalin('caller',cmdm);end